<template>
  <div class="px-[5px] pt-[10px] text-right" v-if="props.showCheckText && procInsId">
    <el-link type="primary" @click="checkHistoryModalVisible = true">审核记录</el-link>
  </div>
  <!-- 基本信息 -->
  <div class="bg-white my-[10px]">
    <BaseHead style="border-bottom: 0">基本信息</BaseHead>
    <BaseTable>
      <tr>
        <td class="td-name">专利名称</td>
        <td>{{ detailData.name }}</td>
        <td class="td-name">专利申请日期</td>
        <td>{{ detailData.publishDate }}</td>
      </tr>
      <tr>
        <td class="td-name">专利类型</td>
        <td>
          <CommonTreeLabel
            :dataList="zlTypeList"
            valueKey="code"
            labelKey="name"
            :value="detailData.modeId"
          />
        </td>
        <td class="td-name">所属单位</td>
        <td>
          <CommonTreeLabel
            isFetch
            paramsName="所有单位"
            valueKey="codeColumn"
            labelKey="valueColumn"
            :value="detailData.publishUnit"
          />
        </td>
      </tr>
      <tr>
        <td class="td-name">承诺书</td>
        <td>
          <template v-if="detailData.fileId">
            {{ detailData.fileName
            }}<el-link
              type="primary"
              @click="handleDownload(detailData.fileId, detailData.fileName)"
              class="ml-[5px]"
              >下载</el-link
            >
          </template>
        </td>
        <td class="td-name">一级学科</td>
        <td>
          <CommonLabel
            :value="detailData.subjectId"
            :dataList="firstSubjectList"
            valueKey="id"
            labelKey="label"
          />
        </td>
      </tr>
    </BaseTable>
  </div>
  <!-- 作者信息 -->
  <div class="bg-white my-[10px]">
    <BaseHead style="border-bottom: 0">作者信息</BaseHead>
    <el-table :data="detailData.authorList" class="w-full" border stripe>
      <el-table-column type="index" label="序号" width="60px" />
      <el-table-column label="作者类型">
        <template #default="{ row }">
          <CommonLabel :value="row.authorType" :dataList="memberTypeList" />
        </template>
      </el-table-column>
      <el-table-column prop="authorName" label="作者姓名" />
      <el-table-column label="学历">
        <template #default="{ row }">
          <CommonTreeLabel
            :value="row.eduLevelId"
            :dataList="educationList"
            valueKey="code"
            labelKey="name"
          />
        </template>
      </el-table-column>
      <el-table-column label="职称">
        <template #default="{ row }">
          <CommonLabel
            :value="row.titleId"
            :dataList="applierTitleList"
            valueKey="id"
            labelKey="label"
          />
        </template>
      </el-table-column>
      <el-table-column label="角色类型">
        <template #default="{ row }">
          <CommonTreeLabel
            :value="row.roleType"
            :dataList="roleTypeList"
            valueKey="code"
            labelKey="name"
          />
        </template>
      </el-table-column>
      <el-table-column prop="authorUnit" label="工作单位"> </el-table-column>
      <el-table-column prop="note" label="备注"></el-table-column>
    </el-table>
  </div>
  <CheckHistoryModal
    v-model="checkHistoryModalVisible"
    :procInsId="procInsId"
    :checker="checker"
    :checkDate="checkDate"
  />
</template>

<script setup>
import CheckHistoryModal from "@/views/project/components/CheckHistoryModal.vue";
import BaseHead from "@/views/project/components/BaseHead.vue";
import BaseTable from "@/views/project/components/BaseTable.vue";
import CommonLabel from "@/views/project/components/CommonLabel.vue";
import CommonTreeLabel from "@/views/project/components/CommonTreeLabel.vue";
import { recordsDetail } from "@/api/kycx";
import { handleDownload } from "@/utils/main";
import useCommonFetch from "@/hooks/useCommonFetch";
const zlTypeList = useCommonFetch("专利类型");
const firstSubjectList = useCommonFetch("一级学科");
const memberTypeList = useCommonFetch("成员类型");
const applierTitleList = useCommonFetch("职称");
const educationList = useCommonFetch("学历");
const roleTypeList = useCommonFetch("专利作者-角色类型");
const props = defineProps({
  operateId: String,
  showCheckText: {
    type: Boolean,
    default: false, //默认不显示审核记录文字
  },
});
const checkHistoryModalVisible = ref(false);
const detailData = ref({});
const procInsId = ref(null); //流程实例id
const checker = ref("");
const checkDate = ref("");
//获取记录详情
const getDetail = async () => {
  try {
    const res = await recordsDetail(props.operateId, 2);
    detailData.value = res.data;
    procInsId.value = res.data.processInstanceId;
    checker.value = res.data.checker;
    checkDate.value = res.data.checkdate;
  } catch (error) {
    console.log(error);
  }
};
onMounted(() => {
  getDetail();
});
</script>

<style scoped lang="scss"></style>
